﻿using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.StaticFiles;
using NPOI.SS.Formula.Functions;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using W.Warehouse.Api.Application.Command.StorageCommand;
using W.Warehouse.Domain;
using W.Warehouse.Domain.DTO;
using W.Warehouse.Read.Api.Application.Command.BinLocationCommands;
using W.Warehouse.Read.Api.Application.Command.StorageCommands;

namespace W.Warehouse.Read.Api.Controllers
{
    /// <summary>
    /// 入库
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class StorageMangeController : ControllerBase
    {
        private readonly IMediator _mediator;
        public StorageMangeController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 入库显示分页查询
        /// </summary>
        /// <param name="commands"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<StoragePageDTO>> GetStorage([FromQuery]StorageSelectCommands commands)
        {
            return await _mediator.Send(commands); 
        }
        /// <summary>
        /// 反填入库信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<FanStorageDTO>> FanStorage([FromQuery] StorageFanCommand command)
        {
            return await _mediator.Send(command);
        }
    }
}
